package com.yunlankeji.stemcells.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.yunlankeji.ganxibaozhijia.R;
import com.yunlankeji.stemcells.model.request.Organization_information;

import java.util.List;

public class Fragment_organization_informationAdapter extends RecyclerView.Adapter<Fragment_organization_informationAdapter.Organization_informationViewHolder> {


    private List<Organization_information>organization_informationList;

    public Fragment_organization_informationAdapter(List<Organization_information> organization_informationList) {
        this.organization_informationList = organization_informationList;
    }

    @NonNull
    @Override
    public Organization_informationViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemview = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_organization_information,parent,false);
        Organization_informationViewHolder organization_informationViewHolder = new Organization_informationViewHolder(itemview);
        return organization_informationViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull Organization_informationViewHolder holder, int position) {
        Organization_information organization_information =organization_informationList.get(position);
        holder.tv_organization_information_name.setText(organization_information.getTv_organization_information_name());
        holder.tv_organization_information_time.setText(organization_information.getTv_organization_information_time());
        holder.tv_organization_information_title.setText(organization_information.getTv_organization_information_title());
        holder.tv_organization_information_message.setText(organization_information.getTv_organization_information_mwssage());
        holder.tv_organization_information_like.setText(organization_information.getTv_organization_information_like());
        holder.iv_organization_information.setImageResource(organization_information.getIv_organization_information());
        holder.iv_organization_information_head.setImageResource(organization_information.getIv_organization_information_head());

    }

    @Override
    public int getItemCount() {
        return organization_informationList.size();
    }

    class Organization_informationViewHolder extends RecyclerView.ViewHolder{
        TextView tv_organization_information_title;
        TextView tv_organization_information_name;
        TextView tv_organization_information_time;
        TextView tv_organization_information_message;
        TextView tv_organization_information_like;
        ImageView iv_organization_information;
        ImageView iv_organization_information_head;

        public Organization_informationViewHolder(View itemView) {
            super(itemView);
            this.tv_organization_information_title = itemView.findViewById(R.id.tv_organization_information_title);
            this.tv_organization_information_name = itemView.findViewById(R.id.tv_organization_information_name);
            this.tv_organization_information_time = itemView.findViewById(R.id.tv_organization_information_time);
            this.tv_organization_information_message = itemView.findViewById(R.id.tv_organization_information_message);
            this.tv_organization_information_like = itemView.findViewById(R.id.tv_organization_information_like);
            this.iv_organization_information = itemView.findViewById(R.id.iv_organization_information);
            this.iv_organization_information_head = itemView.findViewById(R.id.iv_organization_information_head);
        }
    }
}
